home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / pc_board / sms.zip / SMS.PPS
Text File  |  1993-05-21  |  12KB  |  427 lines

  1. ;              Logical Solutions' Simple Menu System   "SMS"
  2. ;              =============================================
  3. ;              Programmed by Hans Hoogstraat  FidoNet 134/10
  4. ;
  5. ; Intro:
  6. ;              SMS present the user with a DOOR menu system
  7. ;              and is very simple configurable by the SYSOP
  8. ;
  9. ;              SMS checks ahead of time if a USER is allowed
  10. ;              to enter a DOOR using his security level and
  11. ;              custom tailors the presented MENU accordingly.
  12. ;
  13. ;              SUBMENU's are supported and the MENU's are
  14. ;              displayed regardless of the USER's Xpert flag.
  15. ;
  16. ;              The USER makes his menu choices by either typing
  17. ;              in a number or the NAME of the DOOR. He can type
  18. ;              as few characters as required to satisfy a unique
  19. ;              selection. If he selects a DOOR for which his
  20. ;              access level is too low, a warning will be displayed
  21. ;              and his selection is voided.
  22. ;
  23. ; Setup:
  24. ;              First the difficult part.
  25. ;
  26. ;              Prior to installation, SMS must be recompiled
  27. ;              replacing the first FOPEN 1,filename by the
  28. ;              proper setting for your system. Unfortunately
  29. ;              PPLC doesn't seem to have any support to obtain
  30. ;              this information from the CNAMES file.
  31. ;
  32. ;              Create a directory, say "C:\PPS" and move the
  33. ;              SMS.PPS and SMS.PPE files into this directory.
  34. ;
  35. ; Step 1:      Now the easy part.
  36. ;
  37. ;              SMS is driven from NAME.LST files in the same
  38. ;              directory as used for the SMS.PPE file.
  39. ;
  40. ;              Use any ASCII editor and create for example DOORS.LST
  41. ;
  42. ; CC 1         My example:
  43. ;  |
  44. ;------------------------ Top    --------------------------------------
  45. ;  Main DOORS Menu
  46. ;  CREDIT   Online Credit Card Subscription.
  47. ;   -
  48. ;  MAIL     Our popular MAIL .QWK reader.
  49. ;   -
  50. ;  PCBHELP  Help with this BBS.
  51. ;   -
  52. ;  GAMES*   Some 80 OnLine GAMES
  53. ;   -
  54. ;   Any DOOR or GAME on this BBS can be immediatly activated by
  55. ;   typing the Name of the DOOR on the PcBoard MAIN command prompt.
  56. ;------------------------ Bottom --------------------------------------
  57. ;
  58. ;  Line 1 = Menu Title
  59. ;
  60. ;  Line 2 till End
  61. ;
  62. ;  A DOOR is specified by name in CC1 followed by a description.
  63. ;
  64. ;  A SubMenu is specified like a DOOR, but suffixed by an '*'
  65. ;
  66. ;  A blank line is specified by a ' -' in CC1-2
  67. ;
  68. ;  Anyline with ';' in CC1 is considered a comment and is skipped
  69. ;  on the presented menu.
  70. ;
  71. ;  Any other information, starting with a ' ' in CC1 is presented
  72. ;  as a comment in the presented menu.
  73. ;
  74. ;  Resulting Menu:
  75. ;
  76. ;  ╔ ## Name ══════════════] DOORS - Main DOORS Menu [═══════════════════╗
  77. ;  ║  1 CREDIT   Online Credit Card Subscription.                        ║
  78. ;  ║                                                                     ║
  79. ;  ║  2 MAIL     Our popular MAIL .QWK reader.                           ║
  80. ;  ║                                                                     ║
  81. ;  ║  3 PCBHELP  Help with this BBS.                                     ║
  82. ;  ║                                                                     ║
  83. ;  ║  4 GAMES    Some 80 OnLine GAMES                                    ║
  84. ;  ║                                                                     ║
  85. ;  ║  Any DOOR or GAME on this BBS can be immediatly activated by        ║
  86. ;  ║  typing the Name of the DOOR on the PcBoard MAIN command prompt.    ║
  87. ;  ╚═════════════════════════════════════════════════════════════════════╝
  88. ;   Enter Selection (1-4,Name,A=Abort,Q=Quit) ? (        )
  89. ;
  90. ;  The DOOR names GAMES* results in a SubMenu described in a simular
  91. ;  file as DOORS.LST, but now called GAMES.LST. There is no limit
  92. ;  to the number of SubMenu's.
  93. ;
  94. ;  The user can type '2' or 'M' to activate the MAIL DOOR.
  95. ;
  96. ;  An 'Q' response, redisplays the Parent Menu, if any.
  97. ;
  98. ;  An 'A' response, just Abort the SMS.PPE and returns the user
  99. ;  to whatever he was doing prior to the Menu.
  100. ;
  101. ; Step 2:
  102. ;
  103. ;  The proper setup has to be included in the PcBoard CMD.LST file
  104. ;  and my example follows:
  105. ;
  106. ;  ╔════════════════════════════════════════════════════════════════
  107. ;  ║                               File Locations
  108. ;  ║
  109. ;  ║         Command     Security  PPE/MNU File -or- Keystroke Repla
  110. ;  ║     ══════════════  ════════  ═════════════════════════════════
  111. ;  ║  1) CREDIT             10     CREDIT
  112. ;  ║  2) MAIL               10     MAIL
  113. ;  ║  3) DOORS              10     M:\PCB\PPS\SMS.PPE DOORS.LST
  114. ;  ║  4) OPEN               10     M:\PCB\PPS\SMS.PPE DOORS.LST
  115. ;  ║  5) GAMES              10     M:\PCB\PPS\SMS.PPE GAMES.LST
  116. ;  ║
  117. ;  ║  ESC=Exit   Alt-R=Repeat a Line   Alt-I=Insert a Line   Alt-D=D
  118. ;  ╚══ 14:41:30 ═══ 05-21-93 ══════ F1 ═ help ════ caps: OFF  num: O
  119. ;
  120. ;  Note that I repeated GAMES, so the user can Enter the GAMES Menu
  121. ;  without going thru the DOORS menu
  122. ;
  123. ;  Now if the SMS PPLC Compiled output would run faster than a 4.77Mhz
  124. ;  PC, things would realy be great. I used the Beta PPLC for my tests.
  125. ;
  126. ;  -------
  127. ;
  128. ;  Enjoy:
  129. ;
  130. ;  Regards,
  131. ;
  132. ;  Hans Hoogstraat
  133. ;
  134.  
  135. string  text
  136. string  opt_str
  137. string  option
  138. integer option_no
  139.  
  140. string  doors[16]    ; Allows for 256 Door Entries
  141. string  door
  142. integer door_sec
  143. integer user_sec
  144.  
  145. string  menu_name
  146.  
  147. string top_line
  148. string bot_line
  149. string mid_line
  150.  
  151. integer i
  152. integer k
  153. integer n
  154. integer no_door_str
  155. integer no_opt
  156. integer menlen
  157. integer textlen
  158. integer optlen
  159. integer prplen
  160.  
  161. boolean done
  162.  
  163. string  C_BG                       ; Menu Background and Border Color
  164. string  C_OP                       ; Menu Name Options
  165. string  C_NM                       ; Menu Numerical Options
  166. string  C_DE                       ; Menu Option Description
  167. string  C_CM                       ; Menu Comment Lines
  168. string  C_IN                       ; Menu Input Prompt
  169. string  C_ER                       ; Menu Input Error
  170.  
  171. cls
  172.  
  173. ; Define the Color Selections
  174.  
  175. C_BG = "@X1F"                      ; Intense White on Blue
  176. C_OP = "@X1E"
  177. C_NM = "@X1F"
  178. C_DE = "@X1B"
  179. C_CM = "@X1F"
  180. C_IN = "@X0E"
  181. C_ER = "@X0C"
  182.  
  183. ; Get the User's Security Level
  184.  
  185. user_sec = cursec()
  186.  
  187. ; Define Size of Menu Box
  188.  
  189. top_line = C_BG+"╔ ## Name ════════════════════════════════════════════════════════════════╗@X0F"
  190. mid_line = C_BG+"║                                                                         ║@X0F"
  191. bot_line = C_BG+"╚═════════════════════════════════════════════════════════════════════════╝@X0F"
  192.  
  193. menlen = len(top_line) - 8
  194.  
  195. ; Read the Doors.Lst file, and build up strings in array DOORS
  196. ; Since the maximum is DOORNAME,,SSS, , we only need to save
  197. ; the first 15 characters. 256/15 = 16 entries per string
  198. ; Each entry is prefixed by a "|" character
  199.  
  200. ; Tailer next command for your system, since PPLC has no command to
  201. ; find it.
  202.  
  203. fopen 1,"m:\pcb\gen\doors.lst",O_RD,S_DN   ; <= Replace to tailor
  204.  
  205. done = false
  206.  
  207. no_door_str = 0
  208. door = ""
  209. i = 0
  210.  
  211. while (!done) do
  212.  
  213.   fget  1,text
  214.  
  215.   if (text == "") then             ; Check if EOF reached.
  216.  
  217.     done = true                    ; If so, flag that we are done
  218.     fclose 1                       ; and close the input file.
  219.  
  220.     if (door != "") then           ; Save a possible last partly
  221.       inc no_door_str              ; built door string
  222.       doors[no_door_str] = door
  223.     endif
  224.  
  225.   endif
  226.  
  227.  
  228.   door = door + "|"+left(text,15)  ; Concatenate this Entry
  229.  
  230.   inc i                            ; Boost no of entries concatenated
  231.  
  232.   if (i == 16) then                ; If we have 16 entry concatenated,
  233.     inc no_door_str                ; save the result and start a new
  234.     doors[no_door_str] = door      ; string.
  235.     door = ""
  236.     i = 0
  237.   endif
  238.  
  239. endwhile                           ; Continue thru the DOORS.LST file
  240.  
  241.  
  242. ; Process the Menu input file
  243.  
  244. menu_name = gettoken()
  245.  
  246. :another_menu
  247.  
  248. cls
  249. no_opt  = 0
  250. opt_str = ""
  251.  
  252. text = ppepath()+menu_name
  253. fopen 1,text,O_RD,S_DN
  254. fget  1,text
  255. text = trim(text," ")
  256.  
  257. i = instr (menu_name,".")
  258. if (i != 0) menu_name = left(menu_name,i-1)
  259.  
  260. text = "] " + C_OP + menu_name + C_BG + " - " + text + " ["
  261.  
  262. menlen = (menlen - len(text) + 8) / 2 + 4
  263.  
  264. text   = left(top_line,menlen)+text+right(top_line,menlen)
  265. menlen = len(text) - 16
  266. println text
  267.  
  268. done  = false
  269.  
  270. while (!done) do
  271.   fget  1,text
  272.  
  273.   if (text == "") then
  274.  
  275.     done = true
  276.     fclose 1
  277.  
  278.   else
  279.  
  280.     door = left(text,1)
  281.  
  282.     if (door != ";") then
  283.  
  284.       if (door == " ") then
  285.         if (left(text,2) == " -") text = ""
  286.         print   left(mid_line,6)
  287.         print   C_CM+text+C_BG
  288.         println right(mid_line,menlen-len(text)+2)
  289.       else
  290.         inc  no_opt
  291.         text = trim(text," ")
  292.         textlen = len(text)
  293.  
  294.         i = instr(text," ");
  295.         if (i == 0) i = textlen
  296.  
  297.         option = upper(rtrim(left(text,i)," "))
  298.         opt_str  = opt_str+"|"+option
  299.  
  300.         door = rtrim(option,"*")
  301.  
  302.         if (door != option) then
  303.           option = door
  304.           optlen = len(option)
  305.           text   = ltrim(right(text,textlen-i)," ")
  306.           door   = ",0"
  307.           goto found_door
  308.         endif
  309.  
  310.         optlen = len(option)
  311.         text   = ltrim(right(text,textlen-i)," ")
  312.         door   = ",255"
  313.  
  314.         for k = 1 to no_door_str
  315.           n = instr(doors[k],"|"+option)
  316.  
  317.           if (n != 0) then
  318.             door = rtrim(mid(doors[k],n+optlen+2,3),",")
  319.             goto found_door
  320.           endif
  321.         next
  322.  
  323.         :found_door
  324.  
  325.         door_sec = s2i(trim(door,","),10)
  326.  
  327.         opt_str  = opt_str+door
  328.  
  329.         print   left(mid_line,6)+C_NM
  330.  
  331.         if (user_sec >= door_sec) then
  332.           print   right(" "+string(no_opt),2)
  333.           print   " "+C_OP
  334.         else
  335.           print   "   "+C_DE
  336.         endif
  337.  
  338.         print   left(option+"         ",8)+" "
  339.         print   C_DE+text+C_BG
  340.         println right(mid_line,menlen-len(text)-10)
  341.         endif
  342.       endif
  343.  
  344.     endif
  345.  
  346. endwhile
  347.  
  348.  
  349. inc no_opt
  350. opt_str = opt_str + "|"
  351. optlen = len(opt_str)
  352.  
  353. text = left(bot_line,6)+right(bot_line,menlen+2)
  354. println text
  355.  
  356. done = false
  357.  
  358. while (!done) do
  359.  
  360.   backup 80
  361.   clreol
  362.   backup 80
  363.  
  364.   text =""
  365.   inputtext C_IN+" Enter Selection (1-"+string(no_opt-1)+",Name,A=Abort,Q=Quit) ",text,15,8
  366.  
  367.   text = upper(strip(text," "))
  368.  
  369.   if (text == "Q") then
  370.     pop menu_name
  371.  
  372.     if (menu_name != "") goto another_menu
  373.  
  374.     stop
  375.   endif
  376.  
  377.   if (text == "A") stop
  378.  
  379.   option_no = s2i(text,10)
  380.  
  381.   if (option_no >= 1 && option_no < no_opt && string(option_no) == text) then
  382.  
  383.     text = opt_str
  384.  
  385.     for i = 1 to option_no
  386.      text = mid(text,instr(text,"|")+1,optlen)
  387.     next
  388.  
  389.     text = left(text,instr(text,"|")-1)
  390.   endif
  391.  
  392.   i = instr (opt_str,"|"+text)
  393.  
  394.   if (i > 0 && instr(mid(opt_str,i+1,optlen),"|"+text) == 0) then
  395.  
  396.     text = mid(opt_str,i+1,optlen)
  397.     i    = instr(text,",")
  398.     door = left(text,i-1)
  399.     door_sec = s2i(trim(mid(text,i+1,3),","),10)
  400.  
  401.     if (user_sec >= door_sec) then
  402.       done = true
  403.     else
  404.       backup 80
  405.       text=""
  406.       inputtext C_IN+" Your access level is too low for ("+C_ER+door+C_IN+") ",text,15,1
  407.     endif
  408.   endif
  409.  
  410. endwhile
  411.  
  412. i = instr(door,"*")
  413.  
  414. if (i == 0) then
  415.    fcreate 1,"pcbstuff.kbd",O_WR,S_DB
  416.    fput    1,menu_name
  417.    fclose  1
  418.  
  419.    kbdstuff door
  420. else
  421.   push menu_name+".LST"
  422.   menu_name = left(door,i-1)+".LST"
  423.   goto another_menu
  424. endif
  425.  
  426.  
  427.